package com.bysj.controller;

import com.bysj.entity.CollectedTopic;
import com.bysj.service.CollectedTopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("collecttopic")
public class CollectedTopicController {
    @Autowired
    CollectedTopicService collectedTopicService;
    //添加收藏的贴子
    @RequestMapping("/addCollectTopic")
    public String addCollectTopic(@RequestBody CollectedTopic collectedTopic){
        collectedTopicService.addCollectTopic(collectedTopic);
        return "success";
    }
    //根据用户id获取用户收藏的贴子
    @RequestMapping("/getCollectTopicByUid")
    public List<CollectedTopic> getCollectTopicByUid(Integer uid){
        return collectedTopicService.getCollectTopicByUid(uid);
    }
    //根据用户和商品id删除已收藏的贴子
    @ResponseBody
    @RequestMapping("/deleteCollectTopicById")
    public String deleteCollectTopicById(Integer tid , Integer uid){
        collectedTopicService.deleteCollectTopicById(tid , uid);
        return "success";
    }
}
